#include("../../comm/ListHead.html")
<div class="layui-fluid layui-anim layui-anim-scale">
    <div class="layui-row layui-col-space5">
        <div class="layui-col-md12 height-auto">
            <div class="layui-card">
                <div class="card-search SearchTable">
                    <p style="float:right">
                        <input type="text" id="keyid" lay-verify="required" placeholder="参数" autocomplete="off"
                               class="table-search-text width120">
                        <input type="text" id="title" lay-verify="required" placeholder="标题" autocomplete="off"
                               class="table-search-text width150">
                        <button class="layui-btn layui-btn-warm layui-btn-sm" lay-event="DoSearch">
                            搜索
                        </button>
                    </p>
                    <i class="layui-icon layui-icon-triangle-r"></i>
                    当前位置 > <span id="titles" class="color_green">系统参数设置</span>
                </div>
                <div class="layui-card-body">
                    <table class="layui-hide" id="table_1" lay-filter="table_1"></table>

                    <script type="text/html" id="table_1_bar_title">
                        <div class="layui-btn-container" style="float:left;">
                            <button class="layui-btn layui-btn-sm btn-change-13" lay-event="ReloadConfig">清除缓存</button>
                            <button class="layui-btn layui-btn-sm layui-btn-disabled" permission-one="btn-edit" lay-event="EditSysConfig">修改参数</button>
                        </div>
                        <div id="bar_desc">缓存有效期为2分钟，修改参数立即同步生效</div>
                    </script>
                    <script type="text/html" id="table_1_bar1">
                        <a class="layui-btn layui-btn-xs btn-change-8" lay-event="EditSysConfig">修改参数</a>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
<script language="JavaScript">

    layui.use(['myTable', 'table', 'form', 'myTool', 'util'], function () {
        table = layui.table, form = layui.form, myTool = layui.myTool;

        tableindex = layui.myTable.render({
            url: 'SysConfigListDataApi'
            , title: '系统参数列表'
            , where: {orderby: 'sindex'}
            , cols: [[
                {type: 'checkbox', width: 36, fixed: true}
                , {field: 'sindex', title: '顺序', width: 70, align: 'center'}
                , {field: 'cf_key', title: '参数', width: 150, align: 'left'}
                , {
                    field: 'cf_value', title: '参数值', align: 'left', width: 180, templet: function (d) {
                        if (d.cf_type == 1) {
                            return d.cf_value;
                        } else if (d.cf_type == 3) {
                            return '<div><img style="cursor:pointer" class="line-img" src=' + d.cf_value + '></div>';
                        }
                    }
                }
                , {field: 'cf_title', title: '参数标题', align: 'left', width: 200}
                , {field: 'cf_desc', title: '参数说明'}
                , {fixed: 'right', title: '操作', toolbar: '#table_1_bar1', width: 120, align: 'center'}
            ]]
            , page: true, limit: 10
        });

        layui.util.event("lay-event", {
            DoSearch: function () {
                tableindex.reload({
                    where: {
                        like: {cf_key: $("#keyid").val(), cf_title: $("#title").val()}
                    }
                    , page: {curr: 1}
                });
            },
            DoSearchMore: function () {
                layui.form.render();
                drawer1.open();
            }
        });

        //头工具栏事件
        table.on('toolbar(table_1)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            myTool.toolbar(this, obj, {
                EditSysConfig: function () {
                    myTool.doSingleSelect(table.checkStatus('table_1'), {key: 'cf_key'}, function (data, keys) {
                        index = top.layer.open({
                            type: 2, offset: '100px', area: ['800px', '500px'], title: ['修改参数[' + data[0].cf_title + ']', 'font-size:15px;'],
                            content: ["sysconfig/EditSysConfig?cf_key=" + data[0].cf_key, 'no']
                            , end: function () {
                                tableindex.reload();
                            }
                        });
                    });
                }
                , ReloadConfig: function () {
                    index = top.layer.confirm('你是否确认清除缓存', {icon: 3, title: '提示', offset: '150px'}, function (index2) {
                        layui.myTool.post('ReloadSysConfigApi', {}, function (result) {
                            tableindex.reload();
                        });
                    });
                }
            });
        });

        //监听行工具事件
        table.on('tool(table_1)', function (obj) {
            myTool.tool(this, obj, {
                EditSysConfig: function (data) {
                    index = top.layer.open({
                        type: 2, offset: '100px', area: ['800px', '500px'], title: ['修改参数[' + data.cf_title + ']', 'font-size:15px;'],
                        content: ["sysconfig/EditSysConfig?cf_key=" + data.cf_key, 'no']
                        , end: function () {
                            tableindex.reload();
                        }
                    });
                }
            });
        });
    });
</script>
</body>
</html>


